if (window.opener) {
	localStorage.setItem("other", location.href);
	window.opener.postMessage(location.href);
	setTimeout(() => {
		window.close();
	}, 1000);
}

const calcVRVP = function (candles) {
	let lower = Math.min(...candles.map(x => x.low));
	let higher = Math.max(...candles.map(x => x.high));
	const count = 20;
	const ary = [];
	const priceStep = (higher - lower) / count;
	for (let i = 0; i < count; i++) {
		const sp = i * priceStep;
		const ep = sp + priceStep;
		let item = { t: 0, b: 0, s: 0 };
		candles.forEach(kline => {
			let n = (kline.open + kline.close) / 2;
			if (n >= sp && n < ep) {
				item.t += kline.volume;
				if (kline.open > kline.close) {
					item.b += kline.volume;
				} else {
					item.s += kline.volume;
				}
			}
		});
		ary.push(item);
	}

	// 统计价格区间内的成交量
	// const volumeProfile = _.reduce(
	// 	candles,
	// 	(result, kline) => {
	// 		const price = (kline.open + kline.close) / 2; // 使用开盘价和收盘价的平均值作为价格
	// 		if (price >= priceRange[0] && price <= priceRange[1]) {
	// 			const volume = kline.volume;
	// 			result[price] = (result[price] || 0) + volume;
	// 		}
	// 		return result;
	// 	},
	// 	{}
	// );
	// vrvpDict.value = volumeProfile;
	// console.log('vrvp', volumeProfile)
};
